package com.xunce.xcworkservice.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.persistence.*;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.Date;
import java.util.List;

/**
 * @author yanlong.guo
 */
@Schema(description = "用户提交实例")
@Data
@EqualsAndHashCode(callSuper = false)
@Table(name = "account")
public class Account {
    /**
     * 账户ID，全局唯一
     */
    @Schema(description = "员工id")
    @TableId(value = "account_id", type = IdType.AUTO)
    private Integer accountId;

    /**
     * 用户名，用于用户登录，不可重复
     */
    @Schema(description = "登录账号")
    @NotBlank(message = "登录账号不能为空")
    @TableField(value = "login_name")
    private String loginName;

    /**
     * 登录密码，用于用户登录
     */
    @TableField(value = "login_pwd")
    @JsonIgnore
    private String loginPwd;

    /**
     * 用户的手机号
     */
    @Schema(description = "手机号")
    @TableField(value = "phone")
    private String phone;

    /**
     * 用户的邮箱地址
     */
    @Schema(description = "邮箱")
    @TableField(value = "email")
    private String email;

    /**
     * 中文名
     */
    @Schema(description = "中文名")
    @NotBlank(message = "中文名不能为空")
    @TableField(value = "account_name")
    private String accountName;

    /**
     * 英文名
     */
    @Schema(description = "英文名")
    @NotBlank(message = "英文名不能为空")
    @TableField(value = "en_name")
    private String enName;

    /**
     * 状态，1-启用，0-禁用
     */
    @Schema(description = "状态，1-启用，0-禁用")
    @TableField(value = "state")
    private Integer state;

    /**
     * 用户所属部门，映射department表
     */
    @Schema(description = "部门身份 1-研发 2-交付 0-无")
    @NotNull(message = "部门身份不能为空")
    @TableField(value = "department_identity")
    private Integer departmentIdentity;

    /**
     * 岗位id，映射station_title表
     */
    @Schema(description = "岗位id")
    @TableField(value = "station_title_id")
    private Integer stationTitleId;

    /**
     * 设置的工单审核人
     */
    @Schema(description = "工单审核人")
    @TableField(value = "review_uid")
    private Integer reviewUid;

    /**
     * 头像地址
     */
    @Schema(description = "头像")
    @TableField(value = "avatar")
    private String avatar;

    /**
     * 性别，0-女，1-男
     */
    @Schema(description = "性别")
    @NotNull(message = "性别不能为空")
    @TableField(value = "sex")
    private Integer sex;

    /**
     * 地址
     */
    @Schema(description = "地址")
    @NotBlank(message = "地址不能为空")
    @TableField(value = "address")
    private String address;

    /**
     * 入职日期
     */
    @Schema(description = "入职日期")
    @TableField(value = "entry_date")
    private Date entryDate;

    /**
     * 离职日期
     */
    @Schema(description = "离职日期")
    @TableField(value = "separate_date")
    private Date separateDate;

    /**
     * 是否需要填写工时
     */
    @Schema(description = "是否需要填写工时")
    @TableField(value = "need")
    private Integer need;

    @Schema(description = "角色id集合")
    @NotEmpty(message = "角色不能为空")
    @TableField(exist = false)
    private List<Integer> roleIds;

    @Schema(description = "角色id集合")
    @TableField(exist = false)
    @NotEmpty(message = "部门不能为空")
    private List<Integer> departmentIds;

    @Schema(description = "用户标识 用于功能选择")
    @TableField(value = "tag")
    private String tag;
}
